package com.woniuxy.intellihome.mapper;

import com.woniuxy.intellihome.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author jobob
 * @since 2021-08-11
 */
public interface UserMapper extends BaseMapper<User> {

    //通过账号获取用户信息
    @Select("select * from m_user where account=#{account}")
    User getByAccount(String account);

    //通过用户id获取account
    @Select("select account from m_user where id=#{id}")
    String getAccountById(int id);

    //通过邮箱获取用户
    @Select("select account from m_user where id=#{id}")
    User getUserByEmail(String email);

    //注册用户
    @Insert("insert into m_user (account,password,email,picture,score,reg_time,code,status)" +
            " values(#{account},#{password},#{email},#{picture},#{score},#{regTime},#{code},#{status})")
    void add(User user);

}
